﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace DHQGHN.PM0.Models.Admin
{
    public class TechnicalLevelModel
    {
        public string TECHNICAL_LEVEL_ID { get; set; }

        [Required(AllowEmptyStrings = false, ErrorMessage = "Bạn chưa nhập tên trình độ")]
        [Remote("CheckExistTechnicalLevelName", "TechnicalLevel", ErrorMessage = "TechnicalLevelNameExist", HttpMethod = "POST", AdditionalFields = "TECHNICAL_LEVEL_ID")]
        [StringLength(255, ErrorMessage = "Độ dài tối đa là 255 ký tự")]
        [Display(Name = "Tên trình độ")]
        public string NAME { get; set; }
        [Required(AllowEmptyStrings = false, ErrorMessage = "Bạn chưa nhập mã trình độ")]
        [Remote("CheckExistTechnicalLevelCode", "TechnicalLevel", ErrorMessage = "TechnicalLevelCodeExist", HttpMethod = "POST", AdditionalFields = "TECHNICAL_LEVEL_ID")]
        [StringLength(12, ErrorMessage = "Độ dài tối đa là 12 ký tự")]
        [RegularExpression(@"^[a-zA-Z0-9]+[a-zA-Z0-9_]*[a-zA-Z0-9]*$", ErrorMessage = "Mã không đúng định dạng")]
        [Display(Name = "Mã trình độ")]
        public string CODE { get; set; }
        [Display(Name = "Mô tả")]
        [StringLength(255, ErrorMessage = "Độ dài tối đa là 255 ký tự")]
        public string DESCRIPTIONS { get; set; }
        public int DELETED { get; set; }
        public int RecordCount { get; set; }

        public const string FIELD_TECHNICAL_LEVEL_ID = "TECHNICAL_LEVEL_ID";
        public const string FIELD_NAME = "NAME";
        public const string FIELD_CODE = "CODE";
        public const string FIELD_DESCRIPTIONS = "DESCRIPTIONS";
        public const string FIELD_DELETED = "DELETED";
        public const string FIELD_RECORD_COUNT = "RecordCount";

        public TechnicalLevelModel()
        {

        }

        public TechnicalLevelModel(DAL.Models.Admin.TechnicalLevelModel appModel)
        {
            // TODO: Complete member initialization
            TECHNICAL_LEVEL_ID = appModel.TECHNICAL_LEVEL_ID;
            CODE = appModel.CODE;
            NAME = appModel.NAME;
            DESCRIPTIONS = appModel.DESCRIPTIONS;
            DELETED = appModel.DELETED;
            RecordCount = appModel.RecordCount;
        }

        internal DAL.Models.Admin.TechnicalLevelModel toDALModel()
        {
            DAL.Models.Admin.TechnicalLevelModel appModel = new DAL.Models.Admin.TechnicalLevelModel
            {
                TECHNICAL_LEVEL_ID = TECHNICAL_LEVEL_ID,
                CODE = CODE,
                NAME = NAME,
                DESCRIPTIONS = DESCRIPTIONS,
                DELETED = DELETED,
                RecordCount = RecordCount
            };
            return appModel;
        }
    }
}
